# Contributor: Francesco Colista <fcolista@alpinelinux.org>
# Maintainer: Bart Ribbers <bribbers@disroot.org>
pkgname=qt5-qtconnectivity
pkgver=5.15.10_git20230612
pkgrel=0
_module="${pkgname#qt5-}"
_pkgver=eeaf42bccd49e8161fbae82d110026d25a5a9a7f
_fullname=$_module-$_pkgver
pkgdesc="QT5 Connectivity Compontents"
url="https://www.qt.io/developers/"
arch="all"
license="( LGPL-2.0-or-later OR GPL-3.0-only OR GPL-2.0-or-later ) AND Qt-GPL-exception-1.0"
makedepends="
	bluez-dev
	qt5-qtbase-dev
	qt5-qtdeclarative-dev
	"
subpackages="$pkgname-dev"
options="!check" # No tests

source="https://dev.alpinelinux.org/archive/qt/$_fullname.tar.xz"
builddir="$srcdir/$_fullname"

_disturl="dev.alpinelinux.org:/archive/qt/"
snapshot() {
	clean
	makedepends="git xz rsync tar" deps
	mkdir -p "$srcdir" && cd "$srcdir"
	git clone --filter=tree:0 https://invent.kde.org/qt/qt/$_module.git .
	git archive --format tar --prefix=$_fullname/ $_pkgver > "$SRCDEST"/$_fullname.tar
	xz -vv -T0 -9 -e "$SRCDEST"/$_fullname.tar
	rsync --progress -La "$SRCDEST"/$_fullname.tar.xz $_disturl
}

prepare() {
	default_prepare

	# We need to make the build system think we're running in a git repository
	# so it correctly symlinks during the build
	mkdir .git
}

build() {
	qmake-qt5
	make
}

package() {
	make INSTALL_ROOT="$pkgdir" install

	# Drop QMAKE_PRL_BUILD_DIR because reference the build dir
	find "$pkgdir/usr/lib" -type f -name '*.prl' \
		-exec sed -i -e '/^QMAKE_PRL_BUILD_DIR/d' {} \;

	install -d "$pkgdir"/usr/share/licenses
	ln -s /usr/share/licenses/qt5-base "$pkgdir"/usr/share/licenses/$pkgname
}

sha512sums="
95edb166174382eb620ad48fc1b269b7b195e7321e4cb0f6309d49f4caa5d2a62a819fddf5b6af36cab4dad9b9195d9c445e8762a94b860e176d39d1b1b81e1e  qtconnectivity-eeaf42bccd49e8161fbae82d110026d25a5a9a7f.tar.xz
"
